import { defineStore } from "pinia";
export const useStore = defineStore("mian", {
    state() {
        return {
            token: "",
            user: null,
            name: "",
            nameaa: ["王哲", "杨超", "韩耀辉", "李东贺"]
        }
    },
    getters: {
        nicname: (state) => {
            if (state.user) {
                return state.user.name
            } else {
                return "宋江"
            }
        },
        getaa: (state) => {
            return (index) => {
                return state.nameaa[index - 1]
            }
        }
        // getname(state){
        //     return state.name1+state.name2
        // }
        //     getname:(state)=>state.name1+state+name2
        //依赖于state生成一个新的值
    },
    actions: { // 可以通过actions 方法，改变 state 里面的值。
        getac(token, user) {
            this.token = token
            this.user = user
        },
        logout(){
            this.token =''
            this.user = null
        }
    },
    persist: {
        enabled: true
    }
})